<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>会员分类</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../layui/css/layui.css">
  <link rel="stylesheet" href="./css/style.css">

</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
<form class="layui-form" action="">
  <div class="jsh-form-content">
  <div class="layui-form-item">
      <label class="layui-form-label">排序</label>
      <div class="layui-input-inline">
        <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入排序" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">分类名称</label>
      <div class="layui-input-inline">
        <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入分类名称" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">佣金比例</label>
      <div class="layui-input-inline">
        <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入佣金比例" class="layui-input">
      </div>
    </div>

  </div>
</form>
</div>    

<script src="../layui/layui.js" charset="utf-8"></script>


<script>
layui.use(['laydate','table'], function(){
  var $ = layui.jquery;
  var laydate = layui.laydate;
  //日期范围
  laydate.render({
    elem: '#test6'
    ,range: true
  });

  var table = layui.table;

  table.render({
    elem: '#test'
    ,height: 'full-110'
    ,title:"会员表"
    ,toolbar: '#toolbarDemo' 
    ,defaultToolbar:[]
    ,url:''
    ,cellMinWidth: 80
    ,cols: [[
      {type:'checkbox'}
      ,{field:'id', title: 'ID',width:80, sort: true}
      ,{field:'username',width:120, title: '角色组'}
      ,{field:'username',width:120, title: '佣金比例'}
      ,{field:'optons', title: '操作',templet:function(){
        return '<div class="layui-btn-container"><button class="layui-btn layui-btn-sm" lay-event="edit">修改</button><button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">删除</button></div>';
      }}
    ]]
    ,page: true
    ,data:[
      {
        id:1,
      },
      {
        id:2,
      }
    ]
  });

table.on('tool(test)', function(obj){ 
  var data = obj.data; //获得当前行数据
  var layEvent = obj.event; 
  var tr = obj.tr; //获得当前行 tr 的DOM对象

  if(layEvent === 'delete'){ //删除
    layer.confirm('真的删除行么', function(index){
      obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
      layer.close(index);
      //向服务端发送删除指令
    });
  } else if(layEvent === 'edit'){ //编辑
      console.log("编辑代码区");
    
    //同步更新缓存对应的值
    obj.update({
      username: '123'
      ,title: 'xxx'
    });
  }
});


  //头工具栏事件
  table.on('toolbar(test)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    if(obj.event == "allDelete"){

      var data = checkStatus.data;
      if(data.length == 0){
        layer.msg('未选中行数！');
      }else{
        console.log("全部删除代码区");
      }
      
    }

  });


  $('#new').on("click",function(){
    layer.open({
      type: 2,
      area: ['80%', '80%'],
      fixed: false, //不固定
      maxmin: true,
      content: 'memberAll.html'
    });
  })

});
</script>

<style>
 html{background: #fff;}
</style>
</body>
</html>